/*
 * @Author: Clark
 * @Email: haixuanwoTxh@gmail.com
 * @Date: 2023-01-04 15:25:15
 * @LastEditors: Clark
 * @LastEditTime: 2023-01-04 15:27:25
 * @Description: file content
 */

#include "apue.h"
#include <fcntl.h>

int main(int argc, char *argv[])
{
    if (2 != argc)
    {
        err_quit("usage: a.out <pathname>");
    }

    if (access(argv[1], R_OK) < 0)
    {
        err_ret("access error for %s", argv[1]);
    }
    else
    {
        printf("read success OK");
    }

    if (open(argv[1], O_RDONLY) < 0)
    {
        err_ret("open error for %s", argv[1]);
    }
    else
    {
        printf("open for reading OK\n");
    }

    exit(0);
}
